﻿var FY0 = "┏━━━━━━━━━━━┓";
var FY1 = "┃       079MAX4       ┃";
var FY2 = "┃ 脚本仿制  　定制脚本 ┃";
var FY3 = "┃ 技术支持 　 游戏顾问 ┃";
var FY4 = "┃ ＷＺ添加　  地图制作 ┃";
var FY5 = "┃ 售登陆器    售下载器 ┃";
var FY6 = "┣━━━━━━━━━━━┫";
var FY7 = "┃唯一QQ: 782772124┃";
var FY8 = "┗━━━━━━━━━━━┛";
var FY9 = "怀旧岛单机交流群免费分享";
var 红色箭头 = "#fUI/UIWindow/Quest/icon6/7#";
var 正方箭头 = "#fUI/Basic/BtHide3/mouseOver/0#";
var status = 0;
var 钥匙ID=4000435;
var 宝箱ID=2430384;
//普通奖池
var itemList1 = [
	//物品id，几率，数字越大概率越大，数量


[1302355, 1, 1, 1],
[1302356, 1, 1, 1],
[1302357, 1, 1, 1],
[1312212, 1, 1, 1],
[1322264, 1, 1, 1],
[1332289, 1, 1, 1],
[1372237, 1, 1, 1],
[1372240, 1, 1, 1],
[1372241, 1, 1, 1],
[1402268, 1, 1, 1],
[1382273, 1, 1, 1],
[1402360, 1, 1, 1],
[1412189, 1, 1, 1],
[1422196, 1, 1, 1],
[1432227, 1, 1, 1],
[1442285, 1, 1, 1],
[1452266, 1, 1, 1],
[1462252, 1, 1, 1],
[1472275, 1, 1, 1],
[1482232, 1, 1, 1],
[1492245, 1, 1, 1],
[1062285, 1, 1, 1],
[1062286, 1, 1, 1],
[1062287, 1, 1, 1],
[1062288, 1, 1, 1],
[1062289, 1, 1, 1],
[1005980, 1, 1, 1],
[1005981, 1, 1, 1],
[1005982, 1, 1, 1],
[1005983, 1, 1, 1],
[1005984, 1, 1, 1],
[1042433, 1, 1, 1],
[1042434, 1, 1, 1],
[1042435, 1, 1, 1],
[1042436, 1, 1, 1],
[1042437, 1, 1, 1],
[1132141, 1, 1, 1],
[1132144, 1, 1, 1],
[1122017, 1, 1, 1],
[1122059, 1, 1, 1],
[1122150, 1, 1, 1],
[1122210, 1, 1, 1],
[1122220, 1, 1, 1],
[1122430, 1, 1, 1],
[1132190, 1, 1, 1],
[1132308, 1, 1, 1],
[1402311, 1, 1, 1],
[1402310, 1, 1, 1],
[1402322, 1, 1, 1],
[1402325, 1, 1, 1],
[1402321, 1, 1, 1],
[1402317, 1, 1, 1],

[1402327, 1, 1, 1],
[1402320, 1, 1, 1],
[1402311, 1, 1, 1],
[1402318, 1, 1, 1],
[1402312, 1, 1, 1],
[1402315, 1, 1, 1],
[1402319, 1, 1, 1],

[1012366, 1, 1, 1],
[1012526, 1, 1, 1],
[1012533, 1, 1, 1],
[1012562, 1, 1, 1],
[1012570, 1, 1, 1],
[1022147, 1, 1, 1],
[1032104, 1, 1, 1],
[1032156, 1, 1, 1],
[1032218, 1, 1, 1],
[1032217, 1, 1, 1],
[1032327, 1, 1, 1],
[1092069, 1, 1, 1],
[1098004, 1, 1, 1],
[1099010, 1, 1, 1],
[1098009, 1, 1, 1],
[1098005, 1, 1, 1]

];

var useNx = 10000000;
var sel0 = -1;
function start() {
	if(FY9 == "怀旧岛单机交流群免费分享" && FY7 == "┃唯一QQ: 782772124┃")
	{
		status = -1;
		action(1, 0, 0);
	}
	else
	{
		cm.sendOk("请勿更改版权信息,否则脚本将无法正常使用");
		cm.dispose();
	}
}

function action(mode, type, selection) {
    if (status == 0 && mode == 0) {
        cm.dispose();
        return;
    }
    if (mode == 1) {
        status++;
    } else {
        status--;
    }

    if (status == 0) {
    	var txt = "#d你可以从创世宝箱里随机获得以下物品#n#k\r\n";
		txt += "#d创世宝箱装备属性为: #b1-300随机全属性\r\n";
    	txt += "#d#L1##b"+红色箭头+" 打开箱子#l\r\n\r\n";
		txt += "\t#b"+正方箭头+" 奖品展示： \r\n";
		
		var txt2 = "";
		for (var i = 0; i < itemList1.length;  i++){
			txt2 += "#i"+itemList1[i][0]+":#";
		}
    	cm.sendSimple(txt + txt2);
    } else if (status == 1) {
		var jobid=cm.getPlayer().getJob();
		//if (jobid==112||jobid==122||jobid==132||jobid==212||jobid==222||jobid==232||jobid==312||jobid==322||jobid==412||jobid==422||jobid==512||jobid==522||jobid==2112||jobid==1112||jobid==1111||jobid==1211||jobid==1311||jobid==1411||jobid==1511){
		sel0 = selection;
		cm.sendGetNumber(""+正方箭头+"#d 请输入开启次数\r\n"
		+"#d每次开启箱子需要消耗1把#r#t4000435##d和1个#r创世宝箱\r\n#r联盟钥匙和创世宝箱#d可以通过怪物掉落/日常/活动等渠道获得",
		1, 1, 99999
		);
		//}else {
         //   cm.sendOk("您好，金币抽奖需要您先完成所有转职后才可以进行抽奖哦！");
         //   cm.dispose();
         //   }
	} else if(status == 2) {
		if (!cm.checkNumSpace(0, selection)) {
			cm.sendOk("背包空间不足"+selection+"格");
			cm.dispose();
			return;
		}
    	switch (sel0) {
			case 1:
                if (!cm.haveItem(宝箱ID,1*selection)) 
				{
					cm.sendOk("#v"+宝箱ID+"#数量不足#r "+(1*selection)+" #k，无法抽奖");
					cm.dispose();
					return;
				} 
				else 
				{
					if(!cm.haveItem(宝箱ID,1*selection))
					{
						cm.sendOk("#v"+宝箱ID+"#数量不足#r "+(1*selection)+" #k，无法抽奖");
						cm.dispose();
						return;
					}
					else
					{
						cm.gainItem(宝箱ID, -(1*selection));
						
					}
				}
				break;
			case 2:
                if (cm.getMeso() < (useNx*selection)) {
					cm.sendOk("金币不足"+(useNx*selection)+"，无法抽奖");
					cm.dispose();
					return;
				} else {
					cm.gainMeso(-useNx*selection);
				}
				break;
			default:
				cm.sendOk("脚本出错，请联系管理员");
				cm.dispose();
				return;
        }
		var txt = "恭喜你获得道具：\r\n";
		for (var i = 0; i < selection; i++) {
			var item;
			var ran = Math.floor(Math.random() * 100);
			var ran1 = null;
			ran1 = finalGift(itemList1);
			if(cm.getBossRankCount("屏蔽"+ran1[0]) > 0){
				cm.gainGachaponItem2(4001126, 1, "秘密箱子", ran1[3]);
			}
			else
			{
				var sjpp = Math.floor(Math.random()*300)+10;
				var suiji1 = Math.floor(Math.random()*300)+1;
				var suiji2 = Math.floor(Math.random()*300)+1;
				var suiji3 = Math.floor(Math.random()*300)+1;
				var suiji4 = Math.floor(Math.random()*300)+1;
				var suijigg = Math.floor(Math.random()*200);
				var suijigg2 = Math.floor(Math.random()*200);
				var suiji5 = Math.floor(Math.random()*200);
				cm.gainItem(ran1[0],suiji1,suiji2,suiji3,suiji4,suiji5,suiji5,suijigg,suijigg2,0,0,0,0,0,0,0);
				cm.喇叭(1,"玩家"+cm.getPlayer().getName()+"从创世宝箱里开出了一件神器");
			}
			cm.gainItem(4000313, 1);
			//cm.gainItem(ran1[0] ,ran1[2])
			//cm.worldMessage("『抽奖捷报』：恭喜玩家."+ cm.getChar().getName() +"  获得["+ Packages.server.MapleItemInformationProvider.getInstance().getName(ran1[0]) +"]让我们热烈的祝福他/她吧！");
			txt += "#v" + ran1[0] + "#\r\n";
			//var result = cm.setBossRankCount("随机奖池抽奖");
			/*
			var ran2 = null;
			if (result%10 == 0) {//十连抽保底
				ran2 = finalGift(itemList1);
				cm.gainItem(ran2[0] ,ran2[2])
				txt += "额外道具：#v" + ran2[0] + "#\r\n";
			}
			*/
		}
		cm.dispose();
		return;
    }
}

function finalGift(lists) {
	var maxChance = 0;
	for (var i in lists) {
		if (lists[i][1] > maxChance) {
			maxChance = lists[i][1];
		}
	}
	var chance = Math.floor(Math.random() * maxChance);
	var finalitem = Array();
	for (var i = 0; i < lists.length; i++) {
		if (lists[i][1] >= chance) {
			finalitem.push(lists[i]);
		}
	}
	var ran1 = Math.floor(Math.random() * finalitem.length);
	return finalitem[ran1];
}